<?php
namespace app\index\controller;

use data\service\ArticleService;
use data\service\ConfigService;
use data\service\TimeLineService;
use data\service\FriendlinkService;
use data\service\NoticeService;

class Index extends BaseController
{
    /**
     * 首页
     * @desc
     * @author 16
     * @date 2018/2/24
     */
    public function index()
    {
        //获取公告
        $notices = new NoticeService();
        $this->assign('nitices',$notices->getNotice());

        //获取推荐文章
        $articles =  new ArticleService();
        $this->assign('articles',$articles->getRecommendAericle());

        //获取站长信息
        $authorInfo = new ConfigService();
        $this->assign('author',$authorInfo->getAuthorInfo());

        //获取热门排行
        $hotArticles = new ArticleService();
        $this->assign('hots',$hotArticles->getHotAericle());

        //获取友情链接
        $friendLink = new FriendlinkService();
        $this->assign('friendLinks',$friendLink->getFriendLink());

        //获取时间链前n的数据
        $lines = new TimeLineService();
        $this->assign('lines',$lines->getLatelyTimeLine());
        //获取时间链前n的数据
        $this->assign('webLines',$lines->getLatelyWebInfo());

        return $this->fetch('home/index');
    }

    /**
     * 关于本站
     * @desc
     * @author 16
     * @date 2018/2/24
     */
    public function about(){
        $configService = new ConfigService();
        //站点信息
        $webInfo = $configService->getWebInfo();
        $this->assign('web',$webInfo);

        //站长信息
        $authorInfo = $configService->getAuthorInfo();
        $this->assign('author',$authorInfo);

        //获取友情链接
        $friendLink = new FriendLinkService();
        $this->assign('friendLinks',$friendLink->getFriendLink());

        return $this->fetch('home/about');
    }

}
